#ifndef PORTABLE_LAZY_TRANSFORMER_H_
#define PORTABLE_LAZY_TRANSFORMER_H_
#include <iostream>
#include <string_view>

#include "include/v8-version.h"
#include "src/ast/scopes.h"
#include "src/base/logging.h"
#include "src/codegen/compiler.h"
#include "src/codegen/script-details.h"
#include "src/execution/isolate.h"
#include "src/interpreter/bytecode-array-builder.h"
#include "src/numbers/conversions.h"
#include "src/objects/elements-kind.h"
#include "src/objects/feedback-vector.h"
#include "src/objects/fixed-array.h"
#include "src/objects/literal-objects-inl.h"
#include "src/objects/literal-objects.h"
#include "src/objects/shared-function-info-inl.h"
#include "src/objects/template-objects.h"
#include "src/pbc/portable-format-helper.h"
#include "src/pbc/portable-format.h"
#include "src/pbc/transform/portable-bytecode-lower.h"
#include "src/pbc/transform/portable-transformer-base.h"

namespace v8 {
namespace internal {
using namespace portable;

class LazyPbcTransformer : public PbcTransformerBase {
 public:
  explicit LazyPbcTransformer(const PbcScript& pbc_script,
                              i::Isolate& v8Isolate, Handle<Script> script,
                              Handle<SharedFunctionInfo> sfi)
      : PbcTransformerBase(pbc_script, v8Isolate, script),
        current_sfi_(sfi),
        current_scope_info_(handle(sfi->scope_info(), &isolate_)) {
    if (i::v8_flags.log_pbc) {
      std::cout << "==============lazy transform==============\n";
    }
  }

  void LazyRun();

 private:
  //   void InitScopeTable();
  Handle<ScopeInfo> GetOrTransformScope(uint32_t scope_id) override;
  Handle<SharedFunctionInfo> TransformFunction(uint32_t func_id) override;
  Handle<BytecodeArray> TransformBytecode(uint32_t func_id) override;
  Handle<TrustedFixedArray> TransformConstantPool(uint32_t func_id) override;

  Handle<SharedFunctionInfo> GetOrCreateFuncData(uint32_t func_id) override;

  //   const PbcScript& pbc_script_;
  // TODO:(wwq) LocalIsolate
  //   Isolate& isolate_;
  //   Handle<Script> script_;
  //   Zone zone_;
  //   AstValueFactory ast_factory_;
  Handle<SharedFunctionInfo> current_sfi_;
  Handle<ScopeInfo> current_scope_info_;
  //   Handle<FixedArray> top_declarations_;
};

}  // namespace internal
}  // namespace v8

#endif  // PORTABLE_LAZY_TRANSFORMER_H_
